<template>
	<view class="forget">
		<view class="content margin-top">
			<!-- 主体 -->
			<view class="main margin-top">
				<view class="main-box">
					<view class="tips">旧密码:</view>
					<wInput v-model="OldPassWord" type="password" placeholder="请输入旧密码" isShowPass></wInput>
				</view>
				<view class="main-box">
					<view class="tips">新密码:</view>
					<wInput v-model="NewPassWord" type="password" maxlength="11" placeholder="请输入新密码" isShowPass></wInput>
				</view>

			</view>
			<wButton text="保存" :rotate="isRotate" @tap.native="savepw()"></wButton>

		</view>
	</view>
</template>

<script>
	var _this;
	import * as Api from '@/syApis/sySet/sySet.js'
	import wInput from '../../components/watch-login/watch-input.vue' //input
	import wButton from '../../components/watch-login/watch-button.vue' //button
	export default {
		data() {
			return {
				OldPassWord: "", //旧密码
				NewPassWord: "", //新密码
				isRotate: false, //是否加载旋转

			}
		},
		// created() {
		// 	let PassWord = uni.getStorageSync("PassWord");
		// 	let NewPassWord = uni.getStorageSync("NewPassWord");
		// 	this.NewPassWord = NewPassWord;
		// 	this.PassWord = PassWord;
		// },
		components: {
			wInput,
			wButton
		},
		// mounted() {
		// 	_this = this;
		// },
		methods: {
			savepw() {
				if (this.isRotate) {
					//判断是否加载中，避免重复点击请求
					return false;
				}
				if (this.OldPassWord.length == 0 || this.NewPassWord.length == 0) {
					if (this.OldPassWord.length == 0 && this.NewPassWord.length == 0) {
						Api.showTip("密码不能为空")
					} else if (this.OldPassWord.length == 0) {
						Api.showTip("旧密码不能为空")
					} else if (this.NewPassWord.length == 0) {
						Api.showTip("新密码不能为空")
					}
				} else {
					var that = this;
					let data = {
						OldPassWord: this.OldPassWord,
						NewPassWord: this.NewPassWord,
					};
					Api.Update_AdminPassword(data, function(res) {
						if (res.state) {
							if (res.data.ErrorMsg == '获取登录信息失败') {

							} else if (res.data.ErrorMsg != "") {
								Api.showTip(res.data.ErrorMsg);
							} else {
								if (res.data.TipsMsg != '') {
									Api.showTip(res.data.TipsMsg);
									
									uni.setStorageSync("NewPassWord",that.NewPassWord);
									console.log("这是存到本地的密码");
									console.log(uni.getStorageSync("NewPassWord"));
									//that.NewPassWord = 
									console.log(res.data.ResultMsg)
									setTimeout(function() {
										uni.redirectTo({
											url: "../my/my"
										})
									}, 1000);
								}

							}
						} else {
							Api.showTip("服务器超时");
						}
					});
				}


				// console.log(e)
			},
			// inputps(e){
			// 	this.PassWord = e.detail.value
			// 	console.log(this.PassWord)
			// },
			// inputnewps(e){
			// 	this.NewPassWord = e.detail.value
			// 	console.log(this.NewPassWord)
			// }

		}
	}
</script>

<style>
	@import url("../../components/watch-login/css/icon.css");
	@import url("../login/css/main");

	.bg1 {
		background-color: rgba(33, 167, 191, 0.8);
		color: #FFFFFF;
	}

	.main-box {
		display: flex;
	}

	.oBorder {
		border: 1rpx #E1D7F0 solid;
	}

	/*新加*/
	.main-list {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		height: 36upx;
		/* Input 高度 */
		color: #333333;
		padding: 32upx 32upx 32upx 10upx;
		margin-top: 24upx;
		margin-bottom: 24upx;
	}

	.main-list1 {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		height: 36upx;
		/* Input 高度 */
		color: #333333;
		padding: 32upx 0 32upx 10upx;
		margin-top: 24upx;
		margin-bottom: 24upx;
	}

	.img {
		width: 32upx;
		height: 32upx;
		font-size: 32upx;
	}

	.main-input {
		flex: 1;
		text-align: left;
		font-size: 28upx;
		/* line-height: 100upx; */
		padding-right: 10upx;
		margin-left: 20upx;
	}

	.vercode {
		color: rgba(0, 0, 0, 0.7);
		font-size: 24upx;
		line-height: 100upx;
	}

	.vercode-run {
		color: rgba(0, 0, 0, 0.4) !important;
	}

	.oBorder {
		width: 75%;
		border: 1rpx #E1D7F0 solid;
		border-radius: 2.5rem;
		-webkit-box-shadow: 0 0 60upx 0 rgba(43, 86, 112, .1);
		box-shadow: 0 0 60upx 0 rgba(43, 86, 112, .1);
	}

	.stop {
		background-color: rgb(96, 188, 204);
	}

	/*历史连接*/
	.ls-box {
		font-size: 16px;
		padding: 5px 0;
		border-bottom: 1rpx #E1D7F0 solid;
		color: #24292E;
	}

	.bg-ls {
		background-color: rgba(33, 167, 191, 1);
		position: fixed;
		width: inherit;
		height: 50px;
		z-index: 100;
	}

	.ls-main {
		max-height: 70%;
	}

	.ls-contain {
		padding-top: 50px;
		height: inherit;
	}
</style>
